package com.ap.core.dao.impl;

import com.ap.core.common.types.ParameterName;
import com.ap.core.dao.AbstractReadOnlyAPCoreBaseJpaDao;
import com.ap.core.dao.ApParameterDao;
import com.ap.core.domain.ApParameter;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

/**
 * User: Ranjit.Singh
 */
public class JpaApParameterDao extends AbstractReadOnlyAPCoreBaseJpaDao<ApParameter, Integer> implements ApParameterDao {


    @Override
    public ApParameter findByKey(final ParameterName parameterName) {
        Criteria criteria = getSession().createCriteria(ApParameter.class);
        criteria.add(Restrictions.eq("parameterName", parameterName));
        return (ApParameter)criteria.uniqueResult();
    }

    @Override
    public ApParameter findById(Integer primaryKey) {
        throw new UnsupportedOperationException("This operation is not supported");
    }


}
